
                <section class="row">
                    <div class="col-12">
                        <div>
                            <h1><?= $template['title'] ?></h1>
                        </div>
                        <div>
                            <?= $this->breadcrumb->output(); ?>
                        </div>
                    </div>
                </section>

                <section class="row">
                    <div class="col-12">
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h2 class="panel-title"><?= $template['title'] ?></h3>
                            </div>
                            <div class="panel-body form-container">
                                <?php if(isset($template['partials']['notifications'])) echo $template['partials']['notifications']; ?>
                                <form id="role-form" method="post" action="<?= base_url() ?>roles/<?= $action ?>" class="form-bordered form-horizontal">
                                    <fieldset>
                                        <legend><?= $template['title'] ?></legend>
                                        <ul>
                                            <li class="form-group row{name_status}">
                                                <label for="name" class="control-label col-2">
                                                    Singular Name *
                                                    <br><small>(Alphanumeric Characters)</small>
                                                </label>
                                                <div class="control-group input-center col-10">
                                                    <div class="input-size col-12">
                                                        <div class="input-group">
                                                            <span class="input-group-addon"><i class="fa fa-user"></i></span>
                                                            <input type="text" name="name" id="name" class="form-control" placeholder="Role Name" value="<?= $name ?>">
                                                        </div>
                                                        <?= form_error('name') ?>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="form-group row{plural_name_status}">
                                                <label for="plural-name" class="control-label col-2">
                                                    Plural Name *
                                                    <br><small>(Alphanumeric Characters)</small>
                                                </label>
                                                <div class="control-group input-center col-10">
                                                    <div class="input-size col-12">
                                                        <div class="input-group">
                                                            <span class="input-group-addon"><i class="fa fa-users"></i></span>
                                                            <input type="text" name="plural-name" id="plural-name" class="form-control" placeholder="Plural Name" value="<?= $plural_name ?>">
                                                        </div>
                                                        <?= form_error('plural-name') ?>
                                                    </div>
                                                </div>
                                            </li>
                                            <li class="form-group row{description_status}">
                                                <label for="description" class="control-label col-2">
                                                    Description
                                                    <br><small>(Long Text)</small>
                                                </label>
                                                <div class="control-group col-10">
                                                    <div class="input-size">
                                                        <textarea name="description" id="description" class="form-control" placeholder="Role Description..."><?= $description ?></textarea>
                                                        <?= form_error('description') ?>
                                                    </div>
                                                </div>
                                            </li>
                                            
                                            <li class="form-group row{fields_status}">
                                                <label for="fields" class="control-label col-2">
                                                    Fields
                                                    <br><small>(Create fields)</small>
                                                </label>
                                                <div class="control-group col-10">
                                                    
                                                    <table id="fields-table" class="table table-striped table-bordered">
                                                        <thead>
                                                            <tr>
                                                                <th>Add/Remove</th>
                                                                <th>Input Type</th>
                                                                <th>Field Name</th>
                                                                <th>Data Type</th>
                                                                <th>Default Value</th>
                                                                <th>Min</th>
                                                                <th>Max</th>
                                                                <th>Required</th>
                                                                <th class="align-center">Other Options</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>

                                                            <tr>
                                                                <td>
                                                                    <span class="input-group-btn">
                                                                        <button type="button" class="btn btn-default refresh"><i class="fa fa-refresh"></i></button>
                                                                        <button type="button" class="btn btn-default add"><i class="fa fa-plus"></i></button>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <select name="fields[id][type]" class="input-type form-control" readonly="readonly">
                                                                        <optgroup label="Text Inputs">
                                                                            <option value="text"> Text Input </option>
                                                                            <option value="email"> Email Input </option>
                                                                            <option value="url"> URL Input </option>
                                                                            <option value="password"> Password Input </option>
                                                                            <option value="textarea"> Text Area </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Text Inputs">
                                                                            <option value="cle"> CLE WYSIWYG </option>
                                                                            <option value="cke"> CKE WYSIWYG </option>
                                                                        </optgroup>
                                                                        </optgroup>
                                                                        <optgroup label="Number Inputs">
                                                                            <option value="number" selected="selected"> Number </option>
                                                                            <option value="spinner"> Spinner </option>
                                                                        </optgroup>
                                                                        <optgroup label="Date Inputs">
                                                                            <option value="time"> Time Picker </option>
                                                                            <option value="date"> Date Picker </option>
                                                                            <option value="date-range"> Date Range Picker </option>
                                                                            <option value="datetime"> Datetime Picker </option>
                                                                            <option value="datetime-range"> Datetime Range Picker </option>
                                                                            <option value="timezone"> Timezone </option>
                                                                        </optgroup>
                                                                        <optgroup label="Data Inputs">
                                                                            <option value="dropdown"> Dropdown </option>
                                                                            <option value="multi-dropdown"> Multi Dropdown </option>
                                                                            <option value="radio"> Radio Button </option>
                                                                            <option value="checkbox"> Checkbox </option>
                                                                            <option value="tagsinput"> Tagsinput </option>
                                                                        </optgroup>
                                                                        <optgroup label="File Inputs">
                                                                            <option value="image-upload"> Image Upload </option>
                                                                            <option value="button-upload"> Button Upload </option>
                                                                            <option value="file-upload"> File Upload </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Inputs">
                                                                            <option value="toggle"> Toggle </option>
                                                                            <option value="color"> Color Picker </option>
                                                                            <option value="masked"> Masked Input </option>
                                                                            <option value="captcha"> Captcha </option>
                                                                            <option value="geolocation"> Geolocation </option>
                                                                        </optgroup>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[id][field-name]" class="field-name form-control" placeholder="id" value="id">
                                                                </td>
                                                                <td>
                                                                    <select name="fields[id][data-type]" class="data-type form-control" readonly="readonly">
                                                                        <option value="int" class="number">Int</option>
                                                                        <option value="int" class="number" selected="selected">Unsigned Int</option>
                                                                        <option value="bigint" class="number">Big Int</option>
                                                                        <option value="decimal" class="number">Decimal</option>
                                                                        <option value="float" class="number">Float</option>
                                                                        <option value="double" class="number">Double</option>
                                                                        <option value="real" class="number">Real</option>
                                                                        <option value="bit" class="number">Bit</option>
                                                                        <option value="bolean" class="number boolean">Boolean</option>
                                                                        <option value="serial" class="number">Serial</option>
                                                                        <option value="date" class="date">Date</option>
                                                                        <option value="datetime" class="date datetime">Datetime</option>
                                                                        <option value="timestamp" class="date datetime">Timestamp</option>
                                                                        <option value="time" class="time">Time</option>
                                                                        <option value="year" class="year">Year</option>
                                                                        <option value="char" class="text">Char</option>
                                                                        <option value="varchar" class="text">Varchar</option>
                                                                        <option value="tinytext" class="text">Tiny Text</option>
                                                                        <option value="text" class="text">Text</option>
                                                                        <option value="mediumtext" class="text">Medium Text</option>
                                                                        <option value="longtext" class="text">Long Text</option>
                                                                        <option value="enum" class="multi-dropdown">Enum</option>
                                                                        <option value="set" class="multi-dropdown">Set</option>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[id][default-value]" class="default-value form-control" placeholder="Default Value" readonly="readonly">
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[id][min-length]" class="min-length form-control spinner" placeholder="0" readonly="readonly">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[id][max-length]" class="max-length form-control spinner" placeholder="10" value="10" readonly="readonly">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="checkbox" name="fields[id][required]" class="required form-control switch" data-on-text="yes" data-off-text="no" checked="checked" readonly="readonly">
                                                                    </div>
                                                                </td>
                                                                <td class="other-options">
                                                                    &nbsp;
                                                                </td>
                                                            </tr>
                                                            
                                                            <tr>
                                                                <td>
                                                                    <span class="input-group-btn">
                                                                        <button type="button" class="btn btn-default remove"><i class="fa fa-minus"></i></button>
                                                                        <button type="button" class="btn btn-default add"><i class="fa fa-plus"></i></button>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <select name="fields[first-name][type]" class="input-type form-control">
                                                                        <optgroup label="Text Inputs">
                                                                            <option value="text" selected="selected"> Text Input </option>
                                                                            <option value="email"> Email Input </option>
                                                                            <option value="url"> URL Input </option>
                                                                            <option value="password"> Password Input </option>
                                                                            <option value="textarea"> Text Area </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Text Inputs">
                                                                            <option value="cle"> CLE WYSIWYG </option>
                                                                            <option value="cke"> CKE WYSIWYG </option>
                                                                        </optgroup>
                                                                        </optgroup>
                                                                        <optgroup label="Number Inputs">
                                                                            <option value="number"> Number </option>
                                                                            <option value="spinner"> Spinner </option>
                                                                        </optgroup>
                                                                        <optgroup label="Date Inputs">
                                                                            <option value="time"> Time Picker </option>
                                                                            <option value="date"> Date Picker </option>
                                                                            <option value="date-range"> Date Range Picker </option>
                                                                            <option value="datetime"> Datetime Picker </option>
                                                                            <option value="datetime-range"> Datetime Range Picker </option>
                                                                            <option value="timezone"> Timezone </option>
                                                                        </optgroup>
                                                                        <optgroup label="Data Inputs">
                                                                            <option value="dropdown"> Dropdown </option>
                                                                            <option value="multi-dropdown"> Multi Dropdown </option>
                                                                            <option value="radio"> Radio Button </option>
                                                                            <option value="checkbox"> Checkbox </option>
                                                                            <option value="tagsinput"> Tagsinput </option>
                                                                        </optgroup>
                                                                        <optgroup label="File Inputs">
                                                                            <option value="image-upload"> Image Upload </option>
                                                                            <option value="button-upload"> Button Upload </option>
                                                                            <option value="file-upload"> File Upload </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Inputs">
                                                                            <option value="toggle"> Toggle </option>
                                                                            <option value="color"> Color Picker </option>
                                                                            <option value="masked"> Masked Input </option>
                                                                            <option value="captcha"> Captcha </option>
                                                                            <option value="geolocation"> Geolocation </option>
                                                                        </optgroup>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[first-name][field-name]" class="field-name form-control" placeholder="first_name" value="first_name">
                                                                </td>
                                                                <td>
                                                                    <select name="fields[first-name][data-type]" class="data-type form-control">
                                                                        <option value="int" class="number">Int</option>
                                                                        <option value="bigint" class="number">Big Int</option>
                                                                        <option value="decimal" class="number">Decimal</option>
                                                                        <option value="float" class="number">Float</option>
                                                                        <option value="double" class="number">Double</option>
                                                                        <option value="real" class="number">Real</option>
                                                                        <option value="bit" class="number">Bit</option>
                                                                        <option value="bolean" class="number boolean">Boolean</option>
                                                                        <option value="serial" class="number">Serial</option>
                                                                        <option value="date" class="date">Date</option>
                                                                        <option value="datetime" class="date datetime">Datetime</option>
                                                                        <option value="timestamp" class="date datetime">Timestamp</option>
                                                                        <option value="time" class="time">Time</option>
                                                                        <option value="year" class="year">Year</option>
                                                                        <option value="char" class="text">Char</option>
                                                                        <option value="varchar" class="text" selected="selected">Varchar</option>
                                                                        <option value="tinytext" class="text">Tiny Text</option>
                                                                        <option value="text" class="text">Text</option>
                                                                        <option value="mediumtext" class="text">Medium Text</option>
                                                                        <option value="longtext" class="text">Long Text</option>
                                                                        <option value="enum" class="multi-dropdown">Enum</option>
                                                                        <option value="set" class="multi-dropdown">Set</option>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[first-name][default-value]" class="default-value form-control" placeholder="Default Value">
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[first-name][min-length]" class="min-length form-control spinner" placeholder="0">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[first-name][max-length]" class="max-length form-control spinner" placeholder="25" value="25">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="checkbox" name="fields[first-name][required]" class="required form-control switch" data-on-text="yes" data-off-text="no" checked="checked">
                                                                    </div>
                                                                </td>
                                                                <td class="other-options">
                                                                    &nbsp;
                                                                </td>
                                                            </tr>
                                                            
                                                            <tr>
                                                                <td>
                                                                    <span class="input-group-btn">
                                                                        <button type="button" class="btn btn-default remove"><i class="fa fa-minus"></i></button>
                                                                        <button type="button" class="btn btn-default add"><i class="fa fa-plus"></i></button>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <select name="fields[last-name][type]" class="input-type form-control">
                                                                        <optgroup label="Text Inputs">
                                                                            <option value="text" selected="selected"> Text Input </option>
                                                                            <option value="email"> Email Input </option>
                                                                            <option value="url"> URL Input </option>
                                                                            <option value="password"> Password Input </option>
                                                                            <option value="textarea"> Text Area </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Text Inputs">
                                                                            <option value="cle"> CLE WYSIWYG </option>
                                                                            <option value="cke"> CKE WYSIWYG </option>
                                                                        </optgroup>
                                                                        </optgroup>
                                                                        <optgroup label="Number Inputs">
                                                                            <option value="number"> Number </option>
                                                                            <option value="spinner"> Spinner </option>
                                                                        </optgroup>
                                                                        <optgroup label="Date Inputs">
                                                                            <option value="time"> Time Picker </option>
                                                                            <option value="date"> Date Picker </option>
                                                                            <option value="date-range"> Date Range Picker </option>
                                                                            <option value="datetime"> Datetime Picker </option>
                                                                            <option value="datetime-range"> Datetime Range Picker </option>
                                                                            <option value="timezone"> Timezone </option>
                                                                        </optgroup>
                                                                        <optgroup label="Data Inputs">
                                                                            <option value="dropdown"> Dropdown </option>
                                                                            <option value="multi-dropdown"> Multi Dropdown </option>
                                                                            <option value="radio"> Radio Button </option>
                                                                            <option value="checkbox"> Checkbox </option>
                                                                            <option value="tagsinput"> Tagsinput </option>
                                                                        </optgroup>
                                                                        <optgroup label="File Inputs">
                                                                            <option value="image-upload"> Image Upload </option>
                                                                            <option value="button-upload"> Button Upload </option>
                                                                            <option value="file-upload"> File Upload </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Inputs">
                                                                            <option value="toggle"> Toggle </option>
                                                                            <option value="color"> Color Picker </option>
                                                                            <option value="masked"> Masked Input </option>
                                                                            <option value="captcha"> Captcha </option>
                                                                            <option value="geolocation"> Geolocation </option>
                                                                        </optgroup>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[last-name][field-name]" class="field-name form-control" placeholder="last_name" value="last_name" required>
                                                                </td>
                                                                <td>
                                                                    <select name="fields[last-name][data-type]" class="data-type form-control">
                                                                        <option value="int" class="number">Int</option>
                                                                        <option value="bigint" class="number">Big Int</option>
                                                                        <option value="decimal" class="number">Decimal</option>
                                                                        <option value="float" class="number">Float</option>
                                                                        <option value="double" class="number">Double</option>
                                                                        <option value="real" class="number">Real</option>
                                                                        <option value="bit" class="number">Bit</option>
                                                                        <option value="bolean" class="number boolean">Boolean</option>
                                                                        <option value="serial" class="number">Serial</option>
                                                                        <option value="date" class="date">Date</option>
                                                                        <option value="datetime" class="date datetime">Datetime</option>
                                                                        <option value="timestamp" class="date datetime">Timestamp</option>
                                                                        <option value="time" class="time">Time</option>
                                                                        <option value="year" class="year">Year</option>
                                                                        <option value="char" class="text">Char</option>
                                                                        <option value="varchar" class="text" selected="selected">Varchar</option>
                                                                        <option value="tinytext" class="text">Tiny Text</option>
                                                                        <option value="text" class="text">Text</option>
                                                                        <option value="mediumtext" class="text">Medium Text</option>
                                                                        <option value="longtext" class="text">Long Text</option>
                                                                        <option value="enum" class="multi-dropdown">Enum</option>
                                                                        <option value="set" class="multi-dropdown">Set</option>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[last-name][default-value]" class="default-value form-control" placeholder="Default Value">
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[last-name][min-length]" class="min-length form-control spinner" placeholder="0">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[last-name][max-length]" class="max-length form-control spinner" placeholder="25" value="25">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="checkbox" name="fields[last-name][required]" class="required form-control switch" data-on-text="yes" data-off-text="no" checked="checked">
                                                                    </div>
                                                                </td>
                                                                <td class="other-options">
                                                                    &nbsp;
                                                                </td>
                                                            </tr>
                                                            
                                                            <tr>
                                                                <td>
                                                                    <span class="input-group-btn">
                                                                        <button type="button" class="btn btn-default remove"><i class="fa fa-minus"></i></button>
                                                                        <button type="button" class="btn btn-default add"><i class="fa fa-plus"></i></button>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <select name="fields[specialty][type]" class="input-type form-control">
                                                                        <optgroup label="Text Inputs">
                                                                            <option value="text" selected="selected"> Text Input </option>
                                                                            <option value="email"> Email Input </option>
                                                                            <option value="url"> URL Input </option>
                                                                            <option value="password"> Password Input </option>
                                                                            <option value="textarea"> Text Area </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Text Inputs">
                                                                            <option value="cle"> CLE WYSIWYG </option>
                                                                            <option value="cke"> CKE WYSIWYG </option>
                                                                        </optgroup>
                                                                        </optgroup>
                                                                        <optgroup label="Number Inputs">
                                                                            <option value="number"> Number </option>
                                                                            <option value="spinner"> Spinner </option>
                                                                        </optgroup>
                                                                        <optgroup label="Date Inputs">
                                                                            <option value="time"> Time Picker </option>
                                                                            <option value="date"> Date Picker </option>
                                                                            <option value="date-range"> Date Range Picker </option>
                                                                            <option value="datetime"> Datetime Picker </option>
                                                                            <option value="datetime-range"> Datetime Range Picker </option>
                                                                            <option value="timezone"> Timezone </option>
                                                                        </optgroup>
                                                                        <optgroup label="Data Inputs">
                                                                            <option value="dropdown"> Dropdown </option>
                                                                            <option value="multi-dropdown"> Multi Dropdown </option>
                                                                            <option value="radio"> Radio Button </option>
                                                                            <option value="checkbox"> Checkbox </option>
                                                                            <option value="tagsinput"> Tagsinput </option>
                                                                        </optgroup>
                                                                        <optgroup label="File Inputs">
                                                                            <option value="image-upload"> Image Upload </option>
                                                                            <option value="button-upload"> Button Upload </option>
                                                                            <option value="file-upload"> File Upload </option>
                                                                        </optgroup>
                                                                        <optgroup label="Advanced Inputs">
                                                                            <option value="toggle"> Toggle </option>
                                                                            <option value="color"> Color Picker </option>
                                                                            <option value="masked"> Masked Input </option>
                                                                            <option value="captcha"> Captcha </option>
                                                                            <option value="geolocation"> Geolocation </option>
                                                                        </optgroup>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[specialty][field-name]" class="field-name form-control" placeholder="speciality" value="speciality">
                                                                </td>
                                                                <td>
                                                                    <select name="fields[specialty][data-type]" class="data-type form-control">
                                                                        <option value="int" class="number">Int</option>
                                                                        <option value="bigint" class="number">Big Int</option>
                                                                        <option value="decimal" class="number">Decimal</option>
                                                                        <option value="float" class="number">Float</option>
                                                                        <option value="double" class="number">Double</option>
                                                                        <option value="real" class="number">Real</option>
                                                                        <option value="bit" class="number">Bit</option>
                                                                        <option value="bolean" class="number boolean">Boolean</option>
                                                                        <option value="serial" class="number">Serial</option>
                                                                        <option value="date" class="date">Date</option>
                                                                        <option value="datetime" class="date datetime">Datetime</option>
                                                                        <option value="timestamp" class="date datetime">Timestamp</option>
                                                                        <option value="time" class="time">Time</option>
                                                                        <option value="year" class="year">Year</option>
                                                                        <option value="char" class="text">Char</option>
                                                                        <option value="varchar" class="text" selected="selected">Varchar</option>
                                                                        <option value="tinytext" class="text">Tiny Text</option>
                                                                        <option value="text" class="text">Text</option>
                                                                        <option value="mediumtext" class="text">Medium Text</option>
                                                                        <option value="longtext" class="text">Long Text</option>
                                                                        <option value="enum" class="multi-dropdown">Enum</option>
                                                                        <option value="set" class="multi-dropdown">Set</option>
                                                                    </select>
                                                                </td>
                                                                <td>
                                                                    <input type="text" name="fields[specialty][default-value]" class="default-value form-control" placeholder="Default Value">
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[specialty][min-length]" class="min-length form-control spinner" placeholder="0">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="text" name="fields[specialty][max-length]" class="max-length form-control spinner" placeholder="25" value="25">
                                                                    </div>
                                                                </td>
                                                                <td>
                                                                    <div class="input-group">
                                                                        <input type="checkbox" name="fields[specialty][required]" class="required form-control switch" data-on-text="yes" data-off-text="no" checked="checked">
                                                                    </div>
                                                                </td>
                                                                <td class="other-options">
                                                                    &nbsp;
                                                                </td>
                                                            </tr>
                                                            
                                                        </tbody>
                                                    </table>
                                                    
                                                    <div class="input-size">
                                                        
                                                        <?= form_error('fields') ?>
                                                    </div>
                                                </div>
                                            </li>

                                            <li class="form-group row{name-status}">
                                                <label for="view" class="control-label col-2">
                                                    Role Permissions *
                                                    <br><small>(Alphanumeric Characters)</small>
                                                </label>
                                                <div class="control-group input-center col-10">
                                                    <div class="input-size col-6">
                                                        
                                                        <table class="table table-hover table-bordered table-responsive">
                                                            <thead>
                                                                <tr>
                                                                    <th class="align-center script_show"><input type="checkbox" name="toggle_all" id="toggle_all" class="toggle"></th>
                                                                    <th>Module Name</th>
                                                                    <?php foreach($permission_set as $permission_title) : ?>
                                                                    <th class="align-center"><?= $permission_title ?></th>
                                                                    <?php endforeach ; ?>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                                <?php
                                                                    foreach($modules as $module) :
                                                                    $module_name            = isset($module['name']) ? strtolower( str_replace(' ', '_', $module['name']) ) : '';
                                                                    $module_permissions     = isset($module['permissions']) ? unserialize($module['permissions']) : '';
                                                                ?>
                                                                <tr>
                                                                    <td class="align-center script_show"><input type="checkbox" name="<?= $module_name ?>" id="<?= $module_name ?>" class="toggle toggle-all"></td>
                                                                    <td><label for="<?= $module_name ?>"><?= $module['name'] ?></label></td>
                                                                    
                                                                    <?php foreach($permission_set as $permission) {
                                                                        $permission = changeCase( $permission, 'human_upper' );
                                                                        $module_permission = in_array($permission, $module_permissions) ? $permission : 'N/A';
                                                                    ?>
                                                                        <td class="align-center">
                                                                            <?php if( $module_permission === 'N/A' ) : ?>
                                                                            N/A
                                                                            <?php else : ?>
                                                                            <input type="checkbox" name="permissions[<?= $module['id'] ?>][<?= $permission ?>]" class="toggle-all <?= $module_name ?>">
                                                                            <?php endif; ?>
                                                                        </td>
                                                                    <?php } ?>
                                                                </tr>
                                                                <?php endforeach; ?>
                                                            </tbody>
                                                        </table>
                                                        
                                                    </div>
                                                </div>
                                            </li>
                                            
                                            <?php if ($add) : ?>
                                            <li class="form-group row">
                                                <label for="add-another" class="control-label col-2">
                                                    Add Another
                                                    <br><small>(Clear Form After Add)</small>
                                                </label>
                                                <div class="control-group col-10">
                                                    <div class="input-size">
                                                        <div class="checkbox">
                                                            <label class="control-label">
                                                                <input type="checkbox" name="add-another" id="add-another" value="yes"<?= $add_another ?>> 
                                                                <small>Do Not Redirect.</small>
                                                            </label>
                                                        </div>
                                                    </div>
                                                </div>
                                            </li>
                                            <?php endif; ?>
                                            
                                        </ul>
                                    </fieldset>

                                    
                                    <div class="submit-group col-12 align-right">
                                        <input type="hidden" name="id" id="id" value="<?= $id ?>">
                                        <input type="submit" name="submit" class="btn btn-primary" value="Save">
                                        <a href="<?= base_url() ?>roles" class="btn btn-default">Cancel</a>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </section>
                <!-- page-script -->
                <script src="<?= base_url() ?>js/modules/roles/role_form.js"></script>